<?php 
header("Pragma: public");
header("Expires: 0");
header("Accept-Ranges: bytes");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/vnd.ms-excel");
header('Content-Disposition: attachment; filename=allvnebudget.xls');
header("Content-Transfer-Encoding: binary");


$total_original_count = 0;

?>
  <table border=1>
  <tr>
	<th>№ п/п &nbsp;</th>
    <th>id</th>
    <th>ФИО</th>
    <th>Оригинал документов</th> 
    <th>Баллы всего </th>  
    <!-- <th>Баллы по предметам</th>  -->           
  </tr>
  <?php 
foreach ($globallist as $globalkey => $value):
	$totalnumber = 0;
	$sorted_abiturients = $value['sorted_abiturients'];
	$abiturients = $value['allabiturients'];
	$profession_id = $value['profession_id'];
	$subjects_ids = $value['subjects_ids'];
	$profession_subjects = $value['profession_subjects'];
	echo '<tr>';
	echo '<td colspan=6>';
	echo '<b>'.$professions[$profession_id].'</b>';
	echo '</td>';
	echo '</tr>';
  	foreach ($sorted_abiturients as $sorted_privilege):
  	$sorted_abiturients = $sorted_privilege['sortedabiturients_ids'];
  	while (list($key, $val) = each($sorted_abiturients)) {
  		echo '<tr>';
  		$abiturient_id = $key;
  		foreach ($abiturients as $abiturient):
  		if ($abiturient['Abiturient']['id'] == $abiturient_id){
  			break;
  		}
  		endforeach;
  		// общий номер
  		echo '<td>';
  		$totalnumber++;
  		echo $totalnumber;
  		echo '</td>';  		
		// id
  		echo '<td>';
  		echo $abiturient['Abiturient']['id'];
  		echo '</td>';
  		// ФИО
  		echo '<td>';
  		echo $abiturient['Abiturient']['lastname'].' ';
  		echo $abiturient['Abiturient']['firstname'].' ';
  		echo $abiturient['Abiturient']['surname'];  	
  		echo '</td>';
  		// оригинал документов
  		echo '<td>';
  		if ($abiturient['Abiturient']['originaleducationdoc']){
  			echo '<font color=green>ДА</font>';
  			$total_original_count++;  			
  		} else {
  			echo '<font color=red>НЕТ</font>';
  		}
  		echo '</td>';  	
  		// баллы всего
  		echo '<td align=center>';
  		echo $val;
  		echo '</td>';
  		// баллы по предметам
/*   		echo '<td>';
  		$total_score = 0;
  		foreach ($subjects_ids as $subject_id):
  		echo $subjects[$subject_id['ProfessionsSubject']['subject_id']];
  		if ($abiturient['Result'] == NULL){
  			echo ' ';
  		}
	  		foreach ($abiturient['Result'] as $result):
	  		if ($subject_id['ProfessionsSubject']['subject_id'] == $result['subject_id']){
	  			$total_score += $result['score'];
	  			echo ' - <font color=red>'.$result['score'].'</font><br /> ';
	  		}
	  		endforeach;
  		endforeach;
  		//	echo '<font color="green">Всего - '.$total_score.'</font>';
  		echo '</td>';   */		
  		echo '</tr>';
  	}
  	endforeach; 
endforeach;  	 
  ?>
</table>


